package com.abso.mp3tunes.locker.ui.preferences;

import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

import com.abso.mp3tunes.locker.ui.IAudioScrobblerConstants;
import com.abso.mp3tunes.locker.ui.LockerPlugin;

/**
 * The MP3tunes Locker preference page.
 * 
 */
public class AudioScrobblerPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	/** Constructs a new page. */
	public AudioScrobblerPreferencePage() {
		super(GRID);
		setPreferenceStore(LockerPlugin.getDefault().getPreferenceStore());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
	 */
	protected void createFieldEditors() {
		FieldEditor usernameField = new StringFieldEditor(IAudioScrobblerConstants.PREF_USERNAME,
				"Username:", getFieldEditorParent()) {
			public void loadDefault() {
				// does nothing (we don't want to clear the field
			}
		};
		addField(usernameField);
		FieldEditor passwordField = new PasswordFieldEditor(IAudioScrobblerConstants.PREF_PASSWORD,
				"Password:", getFieldEditorParent()) {
			public void loadDefault() {
				// does nothing (we don't want to clear the field
			}
		};
		addField(passwordField);
	}

}
